﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TestRedis.Helper;

namespace TestRedis
{
    class Program
    {
        const string RedisCacheName = "GCtestkey";
        static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("1:存入redis  2:取出redis");
                var cotrolType= Console.ReadLine();
                EnOrDeRedis(cotrolType);
           
            }
        }

       static  void EnOrDeRedis(string operate)
        {
            switch (operate)
            {
                case "1":
                    var currentEnMsg = Guid.NewGuid().ToString("N");
                    RedisCacheHelper.Instance().EnQueue(RedisCacheName, new string[] { currentEnMsg });
                    Console.WriteLine("put redis msg:"+currentEnMsg);
                    break;
                default:
                    var deMsg = RedisCacheHelper.Instance().DeQueue(RedisCacheName, 1);
                    Console.WriteLine("取出队列："+((deMsg==null|| deMsg.Length==0)?"无队列！": deMsg[0]));
                    break;
            }
        }
    }
}
